﻿using Rafy;
using Rafy.ComponentModel;
using Rafy.Data;
using Rafy.Domain;
using Rafy.Domain.ORM;
using Rafy.Domain.ORM.Query;
using Rafy.Domain.Validation;
using Rafy.ManagedProperty;
using Rafy.MetaModel;
using Rafy.MetaModel.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Permissions;
using System.Text;
using static Rafy.Domain.ORM.Query.FactoryMethods;

namespace Rafy.Book
{
    /// <summary>
    /// 词语表
    /// </summary>
    [RootEntity]
    public partial class YuWen_Words : BookEntity
    {
        #region 引用属性

        #endregion

        #region 组合子属性

        #endregion

        #region 一般属性
        public static readonly Property<string> F_NameProperty = P<YuWen_Words>.Register(e => e.F_Name);
        /// <summary>
        /// 名称
        /// </summary>
        public string F_Name
        {
            get { return this.GetProperty(F_NameProperty); }
            set { this.SetProperty(F_NameProperty, value); }
        }
        public static readonly Property<string> F_PinYinProperty = P<YuWen_Words>.Register(e => e.F_PinYin);
        /// <summary>
        /// 拼音
        /// </summary>
        public string F_PinYin
        {
            get { return this.GetProperty(F_PinYinProperty); }
            set { this.SetProperty(F_PinYinProperty, value); }
        }

        public static readonly Property<int> F_NameLenProperty = P<YuWen_Words>.Register(e => e.F_NameLen);
        /// <summary>
        /// 词语长度
        /// </summary>
        public int F_NameLen
        {
            get { return this.GetProperty(F_NameLenProperty); }
            set { this.SetProperty(F_NameLenProperty, value); }
        }

        public static readonly Property<string> F_CiXingProperty = P<YuWen_Words>.Register(e => e.F_CiXing);
        /// <summary>
        /// 词性
        /// </summary>
        public string F_CiXing
        {
            get { return this.GetProperty(F_CiXingProperty); }
            set { this.SetProperty(F_CiXingProperty, value); }
        }
        public static readonly Property<string> F_GanQingProperty = P<YuWen_Words>.Register(e => e.F_GanQing);
        /// <summary>
        /// 感情
        /// </summary>
        public string F_GanQing
        {
            get { return this.GetProperty(F_GanQingProperty); }
            set { this.SetProperty(F_GanQingProperty, value); }
        }
        public static readonly Property<string> F_FanTiProperty = P<YuWen_Words>.Register(e => e.F_FanTi);
        /// <summary>
        /// 繁体
        /// </summary>
        public string F_FanTi
        {
            get { return this.GetProperty(F_FanTiProperty); }
            set { this.SetProperty(F_FanTiProperty, value); }
        }
       
        
        public static readonly Property<string> F_JinYiCiProperty = P<YuWen_Words>.Register(e => e.F_JinYiCi);
        /// <summary>
        /// 近义词
        /// </summary>
        public string F_JinYiCi
        {
            get { return this.GetProperty(F_JinYiCiProperty); }
            set { this.SetProperty(F_JinYiCiProperty, value); }
        }

        public static readonly Property<string> F_FanYiCiProperty = P<YuWen_Words>.Register(e => e.F_FanYiCi);
        /// <summary>
        /// 反义词
        /// </summary>
        public string F_FanYiCi
        {
            get { return this.GetProperty(F_FanYiCiProperty); }
            set { this.SetProperty(F_FanYiCiProperty, value); }
        }
        public static readonly Property<string> F_JieShiProperty = P<YuWen_Words>.Register(e => e.F_JieShi);
        /// <summary>
        /// 解释
        /// </summary>
        public string F_JieShi
        {
            get { return this.GetProperty(F_JieShiProperty); }
            set { this.SetProperty(F_JieShiProperty, value); }
        }

        public static readonly Property<string> F_FaYinProperty = P<YuWen_Words>.Register(e => e.F_FaYin);
        /// <summary>
        /// 发音地址
        /// </summary>
        public string F_FaYin
        {
            get { return this.GetProperty(F_FaYinProperty); }
            set { this.SetProperty(F_FaYinProperty, value); }
        }

        public static readonly Property<string> F_PicProperty = P<YuWen_Words>.Register(e => e.F_Pic);
        /// <summary>
        /// 展示图
        /// </summary>
        public string F_Pic
        {
            get { return this.GetProperty(F_PicProperty); }
            set { this.SetProperty(F_PicProperty, value); }
        }

        public static readonly Property<string> F_VideoProperty = P<YuWen_Words>.Register(e => e.F_Video);
        /// <summary>
        /// 视频地址
        /// </summary>
        public string F_Video
        {
            get { return this.GetProperty(F_VideoProperty); }
            set { this.SetProperty(F_VideoProperty, value); }
        }

        public static readonly Property<string> F_HtmlProperty = P<YuWen_Words>.Register(e => e.F_Html);
        /// <summary>
        /// 采集内容
        /// </summary>
        public string F_Html
        {
            get { return this.GetProperty(F_HtmlProperty); }
            set { this.SetProperty(F_HtmlProperty, value); }
        }
        public static readonly Property<string> F_UrlProperty = P<YuWen_Words>.Register(e => e.F_Url);
        /// <summary>
        /// 采集地址
        /// </summary>
        public string F_Url
        {
            get { return this.GetProperty(F_UrlProperty); }
            set { this.SetProperty(F_UrlProperty, value); }
        }
        #endregion

        #region 只读属性

        #endregion
    }

    /// <summary>
    /// 词语表 列表类。
    /// </summary>
    public partial class YuWen_WordsList : BookEntityList<YuWen_Words> { }

    /// <summary>
    /// 词语表 仓库类。
    /// 负责 词语表 类的查询、保存。
    /// </summary>
    public partial class YuWen_WordsRepository : BookEntityRepository
    {
        /// <summary>
        /// 单例模式，外界不可以直接构造本对象。
        /// </summary>
        protected YuWen_WordsRepository() { }

        [RepositoryQuery]
        public virtual YuWen_Words GetByWords(string name)
        {
            var q = this.CreateLinqQuery();
            q = q.Where(e => e.F_Name == name);
            return (YuWen_Words)this.QueryData(q);
        }

       
    }

    /// <summary>
    /// 词语表 配置类。
    /// 负责 词语表 类的实体元数据的配置。
    /// </summary>
    internal class YuWen_WordsConfig : BookEntityConfig<YuWen_Words>
    {
        /// <summary>
        /// 配置实体的元数据
        /// </summary>
        protected override void ConfigMeta()
        {
            //配置实体的所有属性都映射到数据表中。
            Meta.MapTable().MapAllProperties();
        }
    }
}